define([
	'../api',
	'../index',
    'text!./index.html',
    'css!./index.css',
], function(api, ohcard, html, css) {
    return {
        props: {
			isAdult: {
				type: Number,
				default: 0,
			},
	        selectedIds: {
				type: Array,
		        default: [],
	        }
        },
	    mounted:function(){
			this.getCards();
	    },
	    methods: {
			imageOn:function(id){
				return this.selectedIds.includes(id);
			},
		    getCards:function(){
				let vm = this
				api.getCards({is_adult: this.isAdult,type:[1,2]}).then(function(res){
					vm.cards = res.data;
				}).catch(function (err) {
                    Layer.alert(err.msg);
                });
		    },
		    selectCard: function(card){
				this.$emit('select-card',card);
		    }
	    },
        data: function () {
			return {
				cards: [],
		        picSrc: '',
		        isShowPics: false,
			}
        },
        template: html
    };
});